package com.dingding.common.core.config;

import java.math.BigDecimal;

import org.apache.log4j.Logger;

/**
 * 
 * @ClassName: SystemConfig 
 * @Description: 非基础服务相关配置，都在此类中
 * @author CHEHAUNBO 
 * @date 2016年5月27日 上午10:13:43
 * 
 */
public class SystemConfig extends AbstractConfig {

	private Logger log = Logger.getLogger(RedisConfig.class);

	// 系统环境 默认：生产环境
	private static boolean env_system = true;

	// 取消订单、发单次数限制 默认：限制
	private static boolean isLimitNumber = true;

	// 系统访问地址 默认为生产环境
	private static String access_url = Constants.PRODUCT_DOMAIN_NAME;
	// 系统访问地址 默认为生产环境
	private static String access_url_not_port = Constants.PRODUCT_DOMAIN_NAME_NOT_PORT;
	
	// 平台费用 默认为2元
	private static BigDecimal platformCost = new BigDecimal(2);

	// 默认为50
	private static BigDecimal longDistance = new BigDecimal(50);

	// 顺路订单推送，默认：开启推送
	private static OrderPushStatusEnum orderPushStatus = OrderPushStatusEnum.ON;
	
	
	

	/**
	 * 初始化配置
	 * @Title: intitalConfigValue 
	 * @author CHEHAUNBO
	 * 
	 */
	@Override
	public void intitalConfigValue() {

		boolean flag_env_number = prop.getBoolean("env_number");
		boolean flag_env_system = prop.getBoolean("env_system");
		String flag_env = prop.get("env");
		if (!flag_env_number) { // 测试环境
			isLimitNumber = flag_env_number;
			env_system = flag_env_system;
		}
		
		if ("dev".equals(flag_env)) { // 开发环境
			access_url = Constants.DEV_DOMAIN_NAME;
			access_url_not_port = Constants.DEV_WEB_DOMAIN_NAME;
		}else if("test".equals(flag_env)){
			access_url =Constants.TEST_DOMAIN_NAME;
			access_url_not_port = Constants.TEST_DOMAIN_NAMENOT_PORT;
		}

		// 平台费用
		platformCost = new BigDecimal(prop.getDouble("env_platformcost"));
		// 长途距离起点
		longDistance = new BigDecimal(prop.getDouble("env_longdistance"));

		log.info("正在初始化系统相关配置！初始化后的值：" + toString());

	}

	public static boolean isLimitNumber() {
		return isLimitNumber;
	}

	public static void setLimitNumber(boolean isLimitNumber) {
		SystemConfig.isLimitNumber = isLimitNumber;
	}

	public enum OrderPushStatusEnum {
		ON, OFF
	}

	public static boolean isEnv_system() {
		return env_system;
	}

	public static OrderPushStatusEnum getOrderPushStatus() {
		return orderPushStatus;
	}

	public static void setOrderPushStatus(OrderPushStatusEnum orderPushStatus) {
		SystemConfig.orderPushStatus = orderPushStatus;
	}

	public static BigDecimal getPlatformCost() {
		return platformCost;
	}

	public static void setPlatformCost(BigDecimal platformCost) {
		SystemConfig.platformCost = platformCost;
	}

	public static BigDecimal getLongDistance() {
		return longDistance;
	}

	public static void setLongDistance(BigDecimal longDistance) {
		SystemConfig.longDistance = longDistance;
	}

	public static String getAccess_url() {
		return access_url;
	}

	public static void setAccess_url(String access_url) {
		SystemConfig.access_url = access_url;
	}

	public static void setEnv_system(boolean env_system) {
		SystemConfig.env_system = env_system;
	}

	public static String getAccess_url_not_port() {
		return access_url_not_port;
	}

	public static void setAccess_url_not_port(String access_url_not_port) {
		SystemConfig.access_url_not_port = access_url_not_port;
	}

	public String toString() {

		return "系统环境：" + env_system + "[isLimitNumber]:" + isLimitNumber;
	}
	
	/**
	 * @Description 订阅主题的枚举
	 * @author fengshuonan
	 * @date 2016年11月30日 下午11:15:18
	 */
	public enum TagsEnum {
		MESSAGE, PUSH, EMAIL, ACTIVITY, BUSINESS,APPOINT_SPECIAL_ORDER,APPOINT_TAXI_ORDER,NETTY_PUSH
	}
	
	/**
	 * @Description 客户端类型
	 * @author fengshuonan
	 * @date 2016年11月30日 下午11:18:04
	 */
	public enum ClientType {
		iOS, Android
	}

}
